import os
#文件读写
import sys
#
# df=open("../file/d_file.txt","a",encoding="utf8")
# df.write("我是建业")
# df.close()
# df=open("../file/d_file.txt","a",encoding="utf8")
# df.write("\r我是建业")
# df.close()
# df=open("../file/d_file.txt","r+",encoding="utf8")
# df.write("\r我是建业")
# df.close()


df=open("../file/d_file.txt","r",encoding="utf8")
a=df.readlines()
print(type(a))
df.close()
print(os.getcwd())
print(os.path.abspath("."))
print(sys.path[0])
#获取相对路径

print('==========1===========')
abspath = os.getcwd()  # 获取当前路径
rootpath = os.path.abspath('..')  # 获取上级路径
print(abspath)
print(rootpath)

print('==========2===========')
ret = abspath.replace(rootpath, '.', 1)
print(ret)
print('此路径是否为文件夹：%s' % os.path.isdir('../' + ret))
print(__file__)
r=open("../file/d_file.txt","w+",encoding="utf8")
r.write("gseks")
r.close()